/*
CREATE AN ASSISTING DATASET WITH DATA FROM LISA
*/

********************************************************************************

clear
set more		 off
cap   log close 	_all
log using 		"../log/A0_append_LISAind.log", replace 

local vars "lopnr loneink akassa sun2000niva_old year alosdag" 
{ // Append LISA  data from 2000-2018
********************************************************************************
use  	 `vars' using "$rawdatapath/lisa_ind_2000.dta" , clear

*Appending LISA 2001 to 2018
forvalues i = 2001(1)2018{
	append using "$rawdatapath/lisa_ind_`i'.dta", keep(`vars')
}	
}



*Add gender to the LISA data
merge m:1 lopnr using "$rawdatapath/gender.dta"
drop if _merge==2
drop 	_merge

*Rename variables
rename woman female
rename sun2000niva_old utbniv
rename lopnr persid 
rename loneink LISA_loneink

*Destring level of education
replace utbniv="" if utbniv=="*"
destring utbniv, replace


gduplicates report persid year // all good!


*As loneink and akassa are in 100 SEKs, I multiply by 100 to get i comparable to RAMS-data
replace LISA_loneink= LISA_loneink*100
replace akassa  = akassa*100

*Label variabels
lab var utbniv 			"Level of education (LISA)"
lab var LISA_loneink 		"Annual income from LISA"
lab var utbniv 			"Level of education"
lab var akassa			"UI payments in a year (LISA)"
lab var alosdag 		"Annual days unemployed (LISA)"		


*Save
compress
save 		"$datapath/A0_LISAind_2000_2018.dta", replace
log close
